package mr.zhang.controller;

import mr.zhang.dao.domain.Merchant;
import mr.zhang.service.TestMyBatisService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



public class SaveMerChantController extends AbstractController {
	
	private TestMyBatisService testMyBatisService;
	
	

	public TestMyBatisService getTestMyBatisService() {
		return testMyBatisService;
	}



	public void setTestMyBatisService(TestMyBatisService testMyBatisService) {
		this.testMyBatisService = testMyBatisService;
	}



	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		
		// 获取商家名称
				String merchant_name = request.getParameter("merchant_name");

				// 获取商家地址
				String merchant_address = request.getParameter("merchant_address");

				// 获取商家联系电话
				String merchant_cellphone = request.getParameter("merchant_cellphone");

				// 获取商家电子邮件
				String merchant_email = request.getParameter("merchant_email");

				// 获取商家所在的地理位置经度
				String merchant_local_x = request.getParameter("merchant_local_x");

				// 获取商家所在的地理位置纬度
				String merchant_local_y = request.getParameter("merchant_local_y");

				// 获号码取商家QQ号码
				String merchant_QQ = request.getParameter("merchant_QQ");

				// 获取商家微信号码
				String merchant_weixin = request.getParameter("merchant_weixin");
				
				System.out.println(merchant_name);

				Merchant merchant = new Merchant();

				// 设置商家名称
				merchant.setMerchant_name(merchant_name);

				// 设置商家地址
				merchant.setMerchant_address(merchant_address);

				// 设置商家联系电话
				merchant.setMerchant_cellphone(merchant_cellphone);

				// 设置商家电子邮件
				merchant.setMerchant_email(merchant_email);

				// 设置商家所在的地理位置经度
				merchant.setMerchant_local_x(merchant_local_x);

				// 设置商家所在的地理位置纬度
				merchant.setMerchant_local_y(merchant_local_y);

				// 设置号码取商家QQ号码
				merchant.setMerchant_QQ(merchant_QQ);

				// 设置商家微信号码
				merchant.setMerchant_weixin(merchant_weixin);

		
		this.testMyBatisService.saveMerchant(merchant);
		
		return new ModelAndView("redirect:/queryMerchant.do");
	}

}
